package com.socio.utils;

import java.util.Calendar;
import java.util.Date;

public class SocioUtils {

	public static final int NUM_DAY_SEC = 86400000;
	
	public static String dayTimeToString(long time) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date(time));
		
		String dateString = ""+ (calendar.get(Calendar.MONTH)+1); 
		dateString += "/"+ calendar.get(Calendar.DAY_OF_MONTH);
		dateString += "/"+ calendar.get(Calendar.YEAR);

		return dateString;
	}
	
	public static long getDayTimeContainingTime(long time) {
		return time - (time % NUM_DAY_SEC);
	}
	
	public static long getDayStartTime() {
		long now = System.currentTimeMillis();
		long startTime = now - (now % 86400000);
		
		return startTime;
	}
	
	public static long getTodayTime() {
		return getDayTimeContainingTime(System.currentTimeMillis());
	}
	
	public static long nextDayFromTime(long time) {
		long dayTimeOfParamater = getDayTimeContainingTime(time);
		return dayTimeOfParamater + NUM_DAY_SEC;
	}
	
	public static long previousDayFromTime(long time) {
		long dayTimeOfParamater = getDayTimeContainingTime(time);
		return dayTimeOfParamater - NUM_DAY_SEC;
	}
}
